/*
 * @Author: gyc
 * @Date: 2020-04-22 13:20:38
 * @LastEditTime: 2020-04-23 15:37:59
 * @Description: Nuxt测试版
 */
import Vue from 'vue'
import AxiosLoading from './loading.vue'
import anime from 'animejs'

Vue.prototype.$Loading = function (options) {
    //参数判断
    if (options === undefined || options === null) {
        options = {
            content: ''
        }
    } else if (typeof options === 'string' || typeof options === 'number') {
        options = {
            content: options
        }
    }
    //组件构造器
    var axiosloading = Vue.extend(AxiosLoading)
    //挂载到dom
    var component = new axiosloading({
        data: options
    }).$mount()
    //添加dom元素
    document.body.appendChild(component.$el)
    // dom元素渲染完成后执行回调
    // Vue.nextTick(() => {
    //     component.visible = true
    // })
}
//组件注册
AxiosLoading.install = function (Vue) {
    Vue.component(AxiosLoading.name, AxiosLoading);
}
export default AxiosLoading